/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package common.model.message;

import common.model.Visitor;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 *
 * @author nicolas
 */
public class CreateMessage extends AbstractVisitorBasedMessage{

    public CreateMessage(String line) {
        StringTokenizer st = new StringTokenizer(line, " ");
        List<Object> listElems = new ArrayList();
        while(st.hasMoreElements()){
            listElems.add(st.nextElement());
        }
        this.getVisitor().setUserName((String)listElems.get(3));
        this.getVisitor().setX(Double.parseDouble((String)listElems.get(4)));
        this.getVisitor().setZ(Double.parseDouble((String)listElems.get(5)));
        this.getVisitor().setRotation(Double.parseDouble((String)listElems.get(6)));
    }

    public CreateMessage(Visitor visitor) {
        super(visitor);
    }
    
    public String messageToString() {
        return "CREATE " + this.getVisitor().getUserName() + " "
                + this.getVisitor().getX() + " "
                + this.getVisitor().getZ() + " "
                + this.getVisitor().getRotation();
    }
 
}
